﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.AdvTree;
using SyncConfig.Dialog;
using AppCommon.Controls;
using AppCommon;

namespace SyncConfig.Controls
{
    public partial class DependencyTablelList : UserControlBase
    {        
        private Node _TableNode;
        public void DataBind()
        {
            if (CurrentNode.Tag == null)
                _TableNode = CurrentNode.Parent;
            else
                _TableNode = CurrentNode;

            SyncConfigDS.TableOfScopeRow row = _TableNode.Tag as SyncConfigDS.TableOfScopeRow;

            //DataView view = new DataView(FrmMain.MainForm.TreeManipulation.dsSyncConfig.DependencyTable);
            //view.RowFilter = "TableID=" + row.TableID.ToString();
            
            superGridControl1.PrimaryGrid.DataSource = row.GetDependencyTableRows();

        }
        public DependencyTablelList()
        {
            InitializeComponent();
        }

        private void labelLinkX1_Click(object sender, EventArgs e)
        {
            BaseDialog frm = new BaseDialog();
            try
            {
                AddDenpendencyTable ctrl = new AddDenpendencyTable();
                ctrl.CurrentNode = CurrentNode;
                ctrl.BindingNew();
                
                frm.Size = new Size(ctrl.Size.Width + 20, ctrl.Size.Height + 60);
                frm.panelEx1.Controls.Add(ctrl);
                frm.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                frm.Dispose();
            }
            
            
        }
    }
}
